package com.hnguigu.ajax.controller;

import com.hnguigu.ajax.entity.User;
import com.hnguigu.ajax.vo.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/form")
public class FormController {

    @RequestMapping("/test1")
    public String test1() {
        return "test1";
    }

    @RequestMapping("/test2")
    public String test2() {
        return "test2";
    }


    @RequestMapping("/test3")
    public String test3() {
        return "test3";
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public void add(User user) {
        System.out.println(user);
    }

    @RequestMapping(value = "/check")
    @ResponseBody
    public Result check(String name) {
        if ("张三".equals(name)) {
            return new Result("false", "5000", "此用户已占用", null);
        }
        return new Result("true", "2000", "此用户可以使用", null);
    }
}
